home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / subdAssignDefaultShader.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.8 KB  |  89 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  03 Apr 2000
  21. //  Author:         hmw
  22. //
  23. //     Description:
  24. //        Look at the shader connected to the input subdiv surface.
  25. //        If if has no shader assigned then give it the default shader.
  26. //        If it has a shader already, do nothing.
  27. //
  28. //  Procedure Name:
  29. //      subdAssignDefaultShader
  30. //
  31. //  Input Arguments:
  32. //        $subdiv: Subdiv shape to check for a shader.
  33. //                 If $subdiv is a transform, all subdiv shapes below it
  34. //                 will be processed.
  35. //        
  36. //  Return Value:
  37. //      None.
  38. //
  39. global proc subdAssignDefaultShader( string $subdiv ) 
  40. {
  41.     // Sometimes the results of the above command can
  42.     // be transforms above the subds...  Check all the
  43.     // leaf-level subds for shaders.
  44.     //
  45.     string $subdivShapes[] = `ls -dag -lf -type subdiv $subdiv`;
  46.     
  47.     for( $subdiv in $subdivShapes ) {
  48.  
  49.         // Check for connections to "instObjGroups"
  50.         // If any of the connections are a shading engine, then we're done
  51.         //
  52.         int    $foundShadingGroup = false ;
  53.         string $connections[] = `listConnections ($subdiv + 
  54.                                                   ".instObjGroups")`;
  55.         if( size($connections) == 0 ) {
  56.  
  57.             // Check further for connections to "instObjGroups[].objectGroups"
  58.             //
  59.             int $attrSize = `getAttr -size ($subdiv + ".instObjGroups")`;
  60.             int $i;
  61.             for( $i = 0; $i < $attrSize ; $i ++ ) {
  62.                 $connections = `listConnections ($subdiv + 
  63.                                   ".instObjGroups[" + $i + "].objectGroups")`;
  64.  
  65.                 for( $connection in $connections ) {
  66.                     if( `nodeType $connection` == "shadingEngine" ) {
  67.                         $foundShadingGroup = true;
  68.                         break;
  69.                     }
  70.                 }
  71.                 if( $foundShadingGroup ) break;
  72.             }
  73.  
  74.         } else {
  75.         
  76.             for( $connection in $connections ) {
  77.                 if( `nodeType $connection` == "shadingEngine" ) {
  78.                     $foundShadingGroup = true;
  79.                     break;
  80.                 }
  81.             }
  82.         }
  83.         
  84.         if( !$foundShadingGroup ) {
  85.             sets -edit -fe initialShadingGroup $subdiv;
  86.         }
  87.     }
  88. }
  89.